package com.huiminpay.transaction.service;

import com.huiminpay.common.cache.domain.BusinessException;
import com.huiminpay.common.cache.domain.CommonErrorCode;
import com.huiminpay.common.cache.util.StringUtil;
import com.huiminpay.transaction.api.IPayChannelService;
import com.huiminpay.transaction.convert.PayChannelCovert;
import com.huiminpay.transaction.dto.PayChannelDTO;
import com.huiminpay.transaction.entity.PayChannel;
import com.huiminpay.transaction.mapper.PayChannelMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;




@Service
public class IPayChannelServiceImpl implements IPayChannelService {


    @Autowired
    PayChannelMapper payChannelMapper;




    @Override
    public List<PayChannelDTO> queryPayChannels(String platformChannelCode) throws BusinessException{
        //校验非空
        if (StringUtil.isEmpty(platformChannelCode)){
            throw new BusinessException(CommonErrorCode.E_200202);
        }
        //查询当前平台服务下的所有的支付通道
        List<PayChannel> payChannels = payChannelMapper.queryPayChannels(platformChannelCode);
        return PayChannelCovert.INSTANCE.entity2dtoList((payChannels));

    }
}
